package com.cn.crmsystem.service.censusService.impl;

import com.cn.crmsystem.mapper.censusMapper.ForgetReminderMapper;
import com.cn.crmsystem.pojo.ResultJson;
import com.cn.crmsystem.pojo.User;
import com.cn.crmsystem.service.censusService.ForgetReminderService;
import com.cn.crmsystem.utils.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.*;
//from ldk
@Service
public class ForgetReminderServiceImpl implements ForgetReminderService {
    @Autowired
    private ForgetReminderMapper forgetReminderMapper;

    @Override
    public ResultJson ForgetReminderT(String firstSelect,String secondSelect,User user) {
        Map<String,Object> map=new HashMap<>();
        ResultJson resultJson=new ResultJson();
        List list=new ArrayList();
        if(firstSelect!=null && firstSelect.equals("nowDay")){
            map.put("nowDay", DateUtil.dateFormatString(new Date(),"yyyy-MM-dd"));
        }else if(firstSelect!=null && firstSelect.equals("nowMonth")){
            map.put("nowMonth", DateUtil.dateFormatString(new Date(),"yyyy-MM"));
        }else if(firstSelect!=null && firstSelect.equals("nowYear")){
            map.put("nowYear",DateUtil.dateFormatString(new Date(),"yyyy"));
        }else{   //2020-09-07--2020-09-08
            map.put("s_time",firstSelect.split("--")[0]);
            map.put("e_time",firstSelect.split("--")[1]);
        }
        if(secondSelect!=null && secondSelect.equals("myself")){
            map.put("userId",user.getId());
        }else  if(secondSelect!=null && secondSelect.equals("myDepartment")){
            map.put("deptId",user.getDept_id());
        }
        List<Map<String ,Object>> mapList7=forgetReminderMapper.ForgetReminderT7(map);
        List<Map<String ,Object>> mapList15=forgetReminderMapper.ForgetReminderT15(map);
        List<Map<String ,Object>> mapList30=forgetReminderMapper.ForgetReminderT30(map);
        List<Map<String ,Object>> mapList90=forgetReminderMapper.ForgetReminderT90(map);
        List<Map<String ,Object>> mapList180=forgetReminderMapper.ForgetReminderT180(map);
        List<Map<String ,Object>> mapList360=forgetReminderMapper.ForgetReminderT360(map);
        list.add(mapList7);
        list.add(mapList15);
        list.add(mapList30);
        list.add(mapList90);
        list.add(mapList180);
        list.add(mapList360);
        if(list!=null){
            return  resultJson.getSuccess("成功",list);
        }else {
            return  resultJson.getFail("失败");
        }
    }


//    @Override
//    public ResultJson ForgetReminder7(String first, String date, User user) {
//        ResultJson resultJson=new ResultJson();
//        List list=new ArrayList();
//        Map map=new HashMap();
//        map.put("user",user);
//        map.put("date",date);
//        if(date.equals("day")){
//            if(first.equals("myself")){
//                List<Map<String ,Object>> mapList=forgetReminderMapper.ForgetReminderDay7_1_1(map);
//                list.add(mapList);
//            }else if(first.equals("myselfDepartment")){
//                List<Map<String ,Object>> mapList=forgetReminderMapper.ForgetReminderDay7_1_2(map);
//                list.add(mapList);
//            }else if(first.equals("myAndUnderMy")){
//                List<Map<String ,Object>> mapList=forgetReminderMapper.ForgetReminderDay7__1_3(map);
//                list.add(mapList);
//            }
//        }else if (date.equals("month")){
//            if(first.equals("myself")){
//                List<Map<String ,Object>> mapList=forgetReminderMapper.ForgetReminderDay7_2_1(map);
//                list.add(mapList);
//            }else if(first.equals("myselfDepartment")){
//                List<Map<String ,Object>> mapList=forgetReminderMapper.ForgetReminderDay7_2_2(map);
//                list.add(mapList);
//            }else if(first.equals("myAndUnderMy")){
//                List<Map<String ,Object>> mapList=forgetReminderMapper.ForgetReminderDay7_2_3(map);
//                list.add(mapList);
//            }
//        }else if(date.equals("year")){
//            if(first.equals("myself")){
//                List<Map<String ,Object>> mapList=forgetReminderMapper.ForgetReminderDay7_3_1(map);
//                list.add(mapList);
//            }else if(first.equals("myselfDepartment")){
//                List<Map<String ,Object>> mapList=forgetReminderMapper.ForgetReminderDay7_3_2(map);
//                list.add(mapList);
//            }else if(first.equals("myAndUnderMy")){
//                List<Map<String ,Object>> mapList=forgetReminderMapper.ForgetReminderDay7_3_3(map);
//                list.add(mapList);
//            }
//        }else {
//            return resultJson.getFail("查询失败");
//        }
//        if(list!=null){
//            return resultJson.getSuccess("成功",list);
//        }else {
//            return resultJson.getFail("查询失败");
//        }
//    }

//    @Override
//    public ResultJson ForgetReminder15(String first, String date, User user) {
//        ResultJson resultJson=new ResultJson();
//        List list=new ArrayList();
//        Map map=new HashMap();
//        map.put("user",user);
//        map.put("date",date);
//        if(date.equals("day")){
//            if(first.equals("myself")){
//                List<Map<String ,Object>> mapList=forgetReminderMapper.ForgetReminderDay15_1_1(map);
//                list.add(mapList);
//            }else if(first.equals("myselfDepartment")){
//                List<Map<String ,Object>> mapList=forgetReminderMapper.ForgetReminderDay15_1_2(map);
//                list.add(mapList);
//            }else if(first.equals("myAndUnderMy")){
//                List<Map<String ,Object>> mapList=forgetReminderMapper.ForgetReminderDay15__1_3(map);
//                list.add(mapList);
//            }
//        }else if (date.equals("month")){
//            if(first.equals("myself")){
//                List<Map<String ,Object>> mapList=forgetReminderMapper.ForgetReminderDay15_2_1(map);
//                list.add(mapList);
//            }else if(first.equals("myselfDepartment")){
//                List<Map<String ,Object>> mapList=forgetReminderMapper.ForgetReminderDay15_2_2(map);
//                list.add(mapList);
//            }else if(first.equals("myAndUnderMy")){
//                List<Map<String ,Object>> mapList=forgetReminderMapper.ForgetReminderDay15_2_3(map);
//                list.add(mapList);
//            }
//        }else if(date.equals("year")){
//            if(first.equals("myself")){
//                List<Map<String ,Object>> mapList=forgetReminderMapper.ForgetReminderDay15_3_1(map);
//                list.add(mapList);
//            }else if(first.equals("myselfDepartment")){
//                List<Map<String ,Object>> mapList=forgetReminderMapper.ForgetReminderDay15_3_2(map);
//                list.add(mapList);
//            }else if(first.equals("myAndUnderMy")){
//                List<Map<String ,Object>> mapList=forgetReminderMapper.ForgetReminderDay15_3_3(map);
//                list.add(mapList);
//            }
//        }else {
//            return resultJson.getFail("查询失败");
//        }
//        if(list!=null){
//            return resultJson.getSuccess("成功",list);
//        }else {
//            return resultJson.getFail("查询失败");
//        }
//    }
//
//    @Override
//    public ResultJson ForgetReminder30(String first, String date, User user) {
//        ResultJson resultJson=new ResultJson();
//        List list=new ArrayList();
//        Map map=new HashMap();
//        map.put("user",user);
//        map.put("date",date);
//        if(date.equals("day")){
//            if(first.equals("myself")){
//                List<Map<String ,Object>> mapList=forgetReminderMapper.ForgetReminderDay30_1_1(map);
//                list.add(mapList);
//            }else if(first.equals("myselfDepartment")){
//                List<Map<String ,Object>> mapList=forgetReminderMapper.ForgetReminderDay30_1_2(map);
//                list.add(mapList);
//            }else if(first.equals("myAndUnderMy")){
//                List<Map<String ,Object>> mapList=forgetReminderMapper.ForgetReminderDay30__1_3(map);
//                list.add(mapList);
//            }
//        }else if (date.equals("month")){
//            if(first.equals("myself")){
//                List<Map<String ,Object>> mapList=forgetReminderMapper.ForgetReminderDay30_2_1(map);
//                list.add(mapList);
//            }else if(first.equals("myselfDepartment")){
//                List<Map<String ,Object>> mapList=forgetReminderMapper.ForgetReminderDay30_2_2(map);
//                list.add(mapList);
//            }else if(first.equals("myAndUnderMy")){
//                List<Map<String ,Object>> mapList=forgetReminderMapper.ForgetReminderDay30_2_3(map);
//                list.add(mapList);
//            }
//        }else if(date.equals("year")){
//            if(first.equals("myself")){
//                List<Map<String ,Object>> mapList=forgetReminderMapper.ForgetReminderDay30_3_1(map);
//                list.add(mapList);
//            }else if(first.equals("myselfDepartment")){
//                List<Map<String ,Object>> mapList=forgetReminderMapper.ForgetReminderDay30_3_2(map);
//                list.add(mapList);
//            }else if(first.equals("myAndUnderMy")){
//                List<Map<String ,Object>> mapList=forgetReminderMapper.ForgetReminderDay30_3_3(map);
//                list.add(mapList);
//            }
//        }else {
//            return resultJson.getFail("查询失败");
//        }
//        if(list!=null){
//            return resultJson.getSuccess("成功",list);
//        }else {
//            return resultJson.getFail("查询失败");
//        }
//    }
}
